
package petrivis.view;

import java.awt.geom.Rectangle2D;
import java.util.Iterator;
import prefuse.action.layout.Layout;
import prefuse.visual.DecoratorItem;
import prefuse.visual.VisualItem;

/**
 * Class that displays the Decorators in the center of the Decorated item
 * @author Jorge Munoz
 */
public class CenterDecoratorsAction extends Layout{

    public CenterDecoratorsAction(String group) {
        super(group);
    }

    public void run(double frac) {
        Iterator iter = m_vis.items(m_group);
        while ( iter.hasNext() ) {
            DecoratorItem item = (DecoratorItem)iter.next();
            VisualItem node = item.getDecoratedItem();
            Rectangle2D bounds = node.getBounds();
            setX(item, null, bounds.getCenterX());
            setY(item, null, bounds.getCenterY());

        }
    }
}
